package engine.parsers.impl;

import engine.content.IContent;
import engine.parsers.IParser;
import engine.services.IContentService;

/**
 * Title:
 * Description:
 * Copyright:    Copyright (c) 2002
 * Company:
 * @author
 * @version 1.0
 */

public class NonSequiturParser implements IParser{


	// returns the url for the picture after parsing the original url
	@SuppressWarnings({ "unchecked", "rawtypes" })
	public IContent parse(IContent urlContent, IContentService contentService) throws Exception {
		String urlContentStr = urlContent.getContent().toString();
		String gif = "http://images.ucomics.com/comics/nq/";
		// this is the actual parsing to get the url for the FS gif
		int i = urlContentStr.indexOf(gif) + gif.length(); // this is width of our pic
		while(!urlContentStr.substring(i, i+1).equals("\"")) {
			gif += urlContentStr.substring(i, i+1);
		    i++;
		}

		return contentService.getResponse(gif);
	}
}